<?php
require_once("vcl/vcl.inc.php");
require_once("lib/db_connection.php");
//Includes
use_unit("components4phpfull/jtjavascript.inc.php");
use_unit("components4phpfull/jtsitetheme.inc.php");
use_unit("platinumgrid/jtplatinumgrid.inc.php");
use_unit("forms.inc.php");
use_unit("extctrls.inc.php");
use_unit("stdctrls.inc.php");

//Class definition
class user_access_level_list extends Page
{
       public $JSDelete = null;
       public $JSEdit = null;
       public $JTGridUserLevel = null;
       public $imgAdd = null;
       public $JTSiteTheme1 = null;

       function imgAddJSClick($sender, $params)
       {

       ?>
       var win_height = 186;
       var win_width = 408;
       var height = window.outerHeight;
       var width = window.outerWidth;
       var top = Math.round((height-win_height)/2);
       var left = Math.round((width-win_width)/2);
       window.open("user_access_level_create.php", 'Create_Access_Level', 'location=no,height='+win_height+',width='+win_width+',top='+top+',left='+left);

       <?php

       }


       function labelIt($num)
       {
        if($num==1)
        {
         return "read-only";
        }
        if($num==2)
        {
         return "read/write";
        }
       }

       function labelIt2($num)
       {
        if($num==1)
        {
         return "disabled";
        }
        if($num==2)
        {
         return "enabled";
        }
       }

       function JTGridUserLevelShow($sender, $params)
       {
       $grid_arr = array();
       $query_list = "SELECT * FROM accounts_access_level WHERE company_id='".$_SESSION['company_id']."'";
       //$query_list = "SELECT * FROM accounts_access_level WHERE company_id='2'";
       $result_list = mysql_query($query_list) or die("SELECT access levels: ".mysql_error());

        while($row_list = mysql_fetch_array($result_list))
        {
         $edit = "<span onClick=jsedit('".$row_list['id']."') style='cursor:pointer;color:blue;text-decoration:underline;'>".$row_list["account_level"]."</span>";
         $grid_arr[] = array(
         "Access Level" => $edit,
         "Vehicle" => $this->labelIt($row_list["vehicle"]),
         "Spare parts" => $this->labelIt($row_list["part"]),
         "Tires" => $this->labelIt($row_list["tire"]),
         "Route Log" => $this->labelIt($row_list["route"]),
         "Settings" => $this->labelIt2($row_list["settings"]),
         "Tools" => "<img onclick=jsdelete('".$row_list['id']."'); src='image/delete.png' title='delete' style='cursor:pointer'>"
         );
        }
        $this->JTGridUserLevel->setCellData($grid_arr);
       }

       function imgAddJSMouseOut($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.images['imgAdd'].src="image/add_new.png"
       <?php

       }

       function imgAddJSMouseOver($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.images['imgAdd'].src="image/add_new_blue.png"
       <?php

       }


}

global $application;

global $user_access_level_list;

//Creates the form
$user_access_level_list=new user_access_level_list($application);

//Read from resource file
$user_access_level_list->loadResource(__FILE__);

//Shows the form
$user_access_level_list->show();

?>